<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basepath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册绑定</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=yes" name="format-detection" />
    <link href="<%=basepath%>css/index.css" rel="stylesheet" type="text/css">
    <link href="<%=basepath%>css/registered.css" rel="stylesheet" type="text/css">
    <script src="<%=basepath%>js/jquery-1.8.3.min.js"></script>
    <script src="<%=basepath%>js/layer/layer.js"></script>
    <script src="<%=basepath%>js/jquery.md5.js"></script>
</head>
<body>
<%
String code = request.getParameter("code");
String state =request.getParameter("state");
%>
<div class="viewport">
    <div class="header">
        <div class="header-1">
            <a href="javascrpt:void(0)" class="header-2"></a>
            <a href="javascript:history.go(-1)" class="back">返回</a>
            <span class="span-num">WWP11110</span>
        </div>
    </div>
    <div class="content m-top">
        <form method="post" id="myform" action="/wape-web/api/core/centerService">
            <div class="content2">
                <div class="content-2"><input type="text" placeholder="请输入手机号码" id="registerNum" maxlength="15px;" name="registerNum"></div>
                <div class="content2-3"><input type="text" placeholder="请输入真实姓名" maxlength="10px" id="realName" name="realName"></div>
                <div class="content2-3"><input type="password" placeholder="设置密码" maxlength="25px" id="password" name="pwd"></div>
                <div class="content2-3"><input type="password" placeholder="确认密码" maxlength="25px" id="again"></div>
                <div class="content2-4"><input type="checkbox" id="checkbox" checked="checked"><a href="javascript:void(0)" id="protocol">《用户使用协议》</a> </div>
                <input type="hidden" name="serviceCode" value="5001U02" />
                <input type="hidden" name="isWX" id="isWX">
                <input type="hidden" name="openId" id="openId">
                <input type="hidden" name="companyType" value="0" id="companyType">
                <div class="content2-5"><input type="submit" value="提 交" class="submit"></div>
            </div>
        </form>
    </div>
</div>
</body>
<script type="text/javascript">
    /*错误提示*/
    $(function(){
        var error = "${requestScope.returnMsg}";
        if(error != "" && error != "成功!"){
            layer.msg(error,{shadeClose:true,shade:0.1,time:2000});
        }
    });
    /*浏览器识别*/
    $(function(){
        var openId = "${openId}";
        var isWX = "${isWX}";
        $("#openId").val(openId);
        $("#isWX").val(isWX);
    });
    /*隐藏层*/
    $(function(){
        $("#check").click(function(){
            $(".content2-7").toggle(200);

        })
    });
    /*用户协议*/
    $(function(){
        $("#protocol").click(function(){
            layer.open({
                type:2,
                title:"《快来网络用户注册协议》",
                shadeClose:true,
                shade:0.2,
                area:["90%","60%"],
                content:"<%=basepath%>3g/agreement.html"
            })
        })
    });
    /*获取验证码时间*/
    $(function(){
        var wait=60;
        function time(o) {
            if (wait == 0) {
                o.removeAttribute("disabled");
                o.value="免费获取验证码";
                wait = 60;
            } else {
                o.setAttribute("disabled", true);
                o.value="重新发送(" + wait + ")";
                wait--;
                setTimeout(function() {
                            time(o)
                        },
                        1000)
            }
        }
        $("#btn").click(function(){time(this);});
    });
    /*错误提示*/
    $(function(){
        var error = "${requestScope.remsg}";
        if(error != ""){
            layer.msg(error,{shadeClose:true,shade:0.1,time:2000});
        }
    });
    /*注册*/
    $(function(){
        $("#myform").submit(function(){
            var registerNum=$("#registerNum").val();
            var patrn =/^1[3,4,5,6,7,8]\d{9}$/;
            var realName=$("#realName").val();
            var password=$("#password").val();
            var again=$("#again").val();
            var checkbox=$("#checkbox").prop("checked");
            if(registerNum==""){
             layer.msg("请输入手机号",{shadeClose:true,shade:0.1,time:2000});
             return false;
             } 
            else if(!patrn.test(registerNum)){
                layer.msg("输入的手机号码不正确",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else if(realName==""){
                layer.msg("请输入真实姓名",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else if(!realName.match(/^[\u4e00-\u9fa5]{0,}$/)){
                layer.msg("请输入汉字格式姓名",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else if(realName.length>8){
                layer.msg("姓名过长",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else if(password==""){
                layer.msg("请输入密码",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else if(password.length<6){
                layer.msg("密码不能少于6个字符",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else if(password.length>20){
                layer.msg("密码不能大于20个字符",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            /* else if(!password.match(/^[a-zA-Z]\w{5,19}$/)){
             layer.msg("密码请以字母开头，只能包含字母、数字和下划线",{shadeClose:true,shade:0.1,time:2000});
             return false;
             }  */
            else if(again==""){
                layer.msg("请再次输入密码",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else if(password!=again){
                layer.msg("两次密码不一致",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else if(checkbox==""){
                layer.msg("请勾选注册协议",{shadeClose:true,shade:0.1,time:2000});
                return false;
            }
            else{
                var b = $("#password").val();
                var c = $.md5($.md5($.md5(b)));
                $("#password").val(c);
                layer.load();
                setTimeout(function(){
              	  layer.closeAll();
              	  layer.msg("网络异常，请重新尝试！",{shadeClose:true,shade:0.1,time:2000});
              	}, 30000);
            }
        })
    });
</script>
</html>

